package com.learning.spring.cloud.alibaba.ribbon.config.web.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;

/**
 * ClassName: UserController
 * Description:
 * Date: 2021/7/25 23:03 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
@Slf4j
@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    RestTemplate restTemplate;

    /**
     * @param id
     * @return
     */
    @GetMapping("/query/{id}")
    public List<String> selectOrders(@PathVariable("id") Long id) {

        List<String> orderNameList = this.restTemplate.getForObject("http://01-ms-ribbon-order/order/query/user/" + id, List.class);

        return orderNameList;

    }
}
